package com.example.pdr;

public class StepPositioningHandler {

    private static final int EARTH_RADIUS = 6371000; // 地球半径，单位为米
    private final Location currentLocation;

    public StepPositioningHandler(Location initialLocation) {
        this.currentLocation = initialLocation;
    }

    public Location computeNextLocation(float stepSize, float bearing) {
        double bearingInRadians = Math.toRadians(bearing);

        double newX = currentLocation.getxAxis() - stepSize * Math.sin(bearingInRadians);
        double newY = currentLocation.getyAxis() - stepSize * Math.cos(bearingInRadians);

        currentLocation.setxAxis((float) newX);
        currentLocation.setyAxis((float) newY);

        return currentLocation;
    }
}